﻿Public Class login

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text = "" Or TextBox2.Text = "" Then
            MsgBox("Rut o contraseña no deben estar vacios")
            TextBox1.Text = ""
            TextBox2.Text = ""
            Exit Sub
        End If

        Dim str As String
        Dim dataset As New DataSet

        str = "select * from usuarios "
        str += "where usr_rut = '" + TextBox1.Text + "' "
        str += "and usr_clave = '" + TextBox2.Text + "' "
        consulta(str, dataset)

        If dataset.Tables("data").Rows.Count = 0 Then
            MsgBox("Login Invalido!", MsgBoxStyle.Information, "Login")
            Exit Sub
        Else
            MsgBox("Bienvenido Sr(a) " + dataset.Tables("data").Rows(0)("usr_nombre") + " " + dataset.Tables("data").Rows(0)("usr_apellido"), MsgBoxStyle.Information, "Login")
            'Dim usuario As New usuario
            sesion(dataset.Tables("data").Rows(0)("usr_rut"))
            main.LogoutToolStripMenuItem.Enabled = True
            main.IngresoToolStripMenuItem.Enabled = False
            Me.Hide()
        End If
        ' de aca lo sake
    End Sub
End Class